package net.huashitong.config;

import net.huashitong.interceptor.LogInterceptor;
import net.huashitong.interceptor.WeChatInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class InterceptorsConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(logInterceptor())
                .addPathPatterns("/**");
//        registry.addInterceptor(WeChatInterceptor())
//                .addPathPatterns("/money/**");
        super.addInterceptors(registry);
    }

    @Bean
    public LogInterceptor logInterceptor() {
        return new LogInterceptor();
    }

    @Bean
    public WeChatInterceptor WeChatInterceptor() {
        return new WeChatInterceptor();
    }

}
